package main

import "fmt"

type Human struct {
	Name string
	Sex  string
}

func (h *Human) eat() string {
	return "somebody is eating"
}

func (h *Human) walk() string {
	return "somebody is walking"
}

//定义一个子类
type Superman struct {
	Human
	level string
}

//重写2个方法
func (s *Superman) eat() string {
	return "superman is eateing"
}
func (s *Superman) walk() string {
	return "superman is walking"
}

//子类新增方法
func (s *Superman) fly() string {
	return "super can fly"
}
func (s *Superman) print() {
	fmt.Println(s.Sex, s.Name, s.level)
}

func main() {
	human := Human{"nanfeng", "男"}
	superman1 := Superman{human, "15"}
	var superman2 Superman
	superman2.Name = "mingquan"
	superman2.Sex = "男"
	superman2.level = "4"
	fmt.Println(human, superman1, superman2)

	fmt.Println(superman1.walk())
	fmt.Println(superman1.eat())
	fmt.Println(superman1.fly())
	superman1.print()
}
